package com.itboye.mengwu.data.repository;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.utils.BaseErrorListener;
import com.itboye.core.utils.BaseSuccessReqListener;
import com.itboye.core.utils.ByJsonRequest.Builder;
import com.itboye.mengwu.data.interfaces.IAddressQuery;
import com.itboye.mengwu.data.interfaces.IMomZeng;
import com.itboye.mengwu.data.model.AddressQueryModel;
import com.itboye.mengwu.data.model.MomZengBean;

public class MomZengRespository extends BaseNetRepository implements
		IMomZeng<MomZengBean> {
	String api = "100";
	String COLLECTION = "BY_ForumThread_favorites";
	public static final String FaBiaoZhuTi = "BY_ForumThread_add";// 11.3 发表主题

	public MomZengRespository(ICompleteListener listener) {
		// TODO Auto-generated constructor stub
		super(listener);
	}

	@Override
	public void add(MomZengBean model) {
		// TODO Auto-generated method stub
		// Type type = new TypeToken<String>() {
		// }.getType();
		// String apiVer = api;
		// Map<String, Object> map = new HashMap<String, Object>();
		// map.put("fid", model.getFid());// 论坛id 是
		// // map.put("typeid", model.getTypeid());//主题分类id 是
		// map.put("author", model.getAuthor());// 昵称（nickname）是
		// map.put("message", model.getMessage());// 主题帖内容 是
		// map.put("subject", model.getSubject());// 标题 是
		// map.put("author_id", model.getUid());// 用户id（uid）是
		// if (model.getAttachments() != null)
		// map.put("attachments", model.getAttachments());//
		// 图片附件组(eg:1,3,4)由上传图片后返回的各图片id组合而成，若无则不传
		//
		// (new Builder<String>())
		// .setTypeVerParamsAndReturnClass(FaBiaoZhuTi, apiVer, map, type)
		// .requestListener(
		// new BaseSuccessReqListener<String>(getListener()))
		// .errorListener(new BaseErrorListener(getListener()))
		// .desEncodeThenBuildAndSend();
	}

	@Override
	public void delete(MomZengBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(MomZengBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(MomZengBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public List<MomZengBean> queryYouHuiQuan(MomZengBean model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void collection(String tid, String uid, String favorite_value) {
		// TODO Auto-generated method stub
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		params.put("tid", tid);
		params.put("favorite_value", favorite_value);

		// 目前最简化调用
		// START
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(COLLECTION, apiVer, params,
						String.class)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void cancleCollection(String tid, String uid, String favorite_value) {
		// TODO Auto-generated method stub
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		params.put("tid", tid);
		params.put("favorite_value", favorite_value);

		// 目前最简化调用
		// START
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(COLLECTION, apiVer, params,
						String.class)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

}
